#include<queue>
#include<iostream>
using namespace std;

struct node {
	int x, y, pre;
} path[50];

bool vis[10][10];
int maze[10][10];
int dx[] = {0, -1, 1, 0, 0};
int dy[] = {0, 0, 0, -1, 1};

void Print(node x) {
	if (x.pre == -1)
		cout << "(" << x.x - 1 << ", " << x.y - 1 << ")" << endl;
	else {
		Print(path[x.pre]);
		cout << "(" << x.x - 1 << ", " << x.y - 1 << ")" << endl;
	}
}

void bfs(int x, int y) {
	node p;
	p = {x, y, -1};
	vis[x][y] = true;
	path[1] = p;
	int head, tail;
	head = 1, tail = 2;
	while (head < tail) {
		node t = path[head];
		if (t.x == 5 && t.y == 5) {
			Print(t);
			return ;
		}
		for (int i = 1; i <= 4; i++) {
			int xx = t.x + dx[i];
			int yy = t.y + dy[i];
			if (xx < 1 || xx > 5 || yy < 1 || yy > 5 || vis[xx][yy] || maze[xx][yy])
				continue;
			path[tail++] = {xx, yy, head};
			vis[xx][yy] = true;
		}
		head++;
	}
}

int main() {
	for (int i = 1; i <= 5; i++)
		for (int j = 1; j <= 5; j++)
			cin >> maze[i][j];
	bfs(1, 1);
	return 0;
}

